<?php

namespace App\Models;

use App\Models\Work\Gift;
use App\Models\School\Classes;
use App\Models\School\Subject;
use App\Models\User\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\DB;

class Work extends Model
{
    protected $table = 'jxt_works';
    public $primaryKey = 'work_id';

    const CREATED_AT = 'create_at';
    const UPDATED_AT = null;

    public function user()
    {
        return $this->belongsTo(User::class,'create_by','id')
            ->select(['id','username','avatar','telephone']);
    }

    public function classes()
    {
        return $this->belongsTo(Classes::Class,'class_id','class_id');
    }

    public function subject()
    {
        return $this->belongsTo(Subject::Class,'class_subject_id','class_subject_id');
    }

    public function gifts()
    {
        return $this->hasMany(Gift::Class,'work_id','work_id');
    }


    
}
